/***
 * Copyright (c) 2010 readyState Software Ltd
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may
 * not use this file except in compliance with the License. You may obtain
 * a copy of the License at
 * http://www.apache.org/licenses/LICENSE-2.0
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * 
 */

package fr.enseirb.mycub.component.map;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.location.Location;
import android.net.Uri;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.google.android.maps.GeoPoint;
import com.google.android.maps.OverlayItem;

import fr.enseirb.mycub.R;
import fr.enseirb.mycub.activity.bike.StationDetailsActivity;
import fr.enseirb.mycub.db.BikeDBConstants;
import fr.enseirb.mycub.db.BikeDBHelper;
import fr.enseirb.mycub.db.DBAdapter;
import fr.enseirb.mycub.db.StationsProvider;
import fr.enseirb.mycub.service.LocationService;
import fr.enseirb.mycub.utils.Utils;

/**
 * A view representing a MapView marker information balloon.
 * <p>
 * This class has a number of Android resource dependencies:
 * <ul>
 * <li>drawable/balloon_overlay_bg_selector.xml</li>
 * <li>drawable/balloon_overlay_close.png</li>
 * <li>drawable/balloon_overlay_focused.9.png</li>
 * <li>drawable/balloon_overlay_unfocused.9.png</li>
 * <li>layout/balloon_map_overlay.xml</li>
 * </ul>
 * </p>
 * 
 * @author Jeff Gilfelt
 * 
 */
public abstract class BalloonOverlayViewStations<Item extends OverlayItem> extends FrameLayout {

	protected int mBottomOffset;

	/**
	 * Create a new BalloonOverlayView.
	 * 
	 * @param context
	 *            - The activity context.
	 * @param balloonBottomOffset
	 *            - The bottom padding (in pixels) to be applied when rendering
	 *            this view.
	 */
	public BalloonOverlayViewStations(Context context, int offset) {

		super(context);

	}

	/**
	 * Sets the view data from a given overlay item.
	 * 
	 * @param item
	 *            - The overlay item containing the relevant view data (title
	 *            and snippet).
	 */
	public abstract void setData(Item item, Location location);
	
	public void setBalloonBottomOffset(int offset) {
		int old = mBottomOffset;
		mBottomOffset = offset;
		if (old != mBottomOffset) {
			setPadding(10, 0, 10, offset);
			invalidate();
		}
	}
	
	protected abstract void showStationDetails(Uri uri);

	protected abstract void showStationDetails(String id);

}
